﻿CREATE PROCEDURE [acms].[Post_GetByPostGuid]
	@SiteId int,
	@PostGuid UniqueIdentifier, 
	@SiteVersion DateTime
AS
	declare @tmp DateTime
	set @tmp = acms.GetPublishDate(@SiteId, @SiteVersion);
	if(@tmp is null and @SiteVersion is not null)
		return;
		
	SELECT a.*, b.ParentPath, b.PublishDate as SiteVersion 
	From Post_View a
		inner join PostPositions b on a.Id = b.PostId and isNull(b.PublishDate, '9999/12/31') = isNull(@tmp, '9999/12/31')
	Where PostGuid = @PostGuid
		
RETURN 0;